<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

// ------------------------------------------------------------------------

/**
 * Application
 *
 */
class Add_app extends K9_Deploy_Controller
{
	/**
     * Constructor
     *
     * @access  public
     * @return  void
     */
	public function __construct()
	{
		parent::__construct();	
		$this->_check_permit();
		$this->load->model('deploy/app_info_model');
	}
	
	// ------------------------------------------------------------------------
	
	/**
     * Default entrance
     *
     * @access  public
     * @param   int
     * @return  void
     */
	public function view()
	{
		$data['language'] = $this->language;
		
		if ($this->session->userdata('uid'))
		{	
			$this->array = $this->uri->uri_to_assoc(4);
			$this->_template ( $this->language . '/add_app', $data );
		}
		else
		{
			$this->load->view($this->language.'/login',$data);
		}
	}

	public function add()
	{
		$data['app_name'] = $this->input->post('app_name');
		$data['type'] = $this->input->post('type');
		$data['git_url'] = $this->input->post('git_url');
		$data['ci_flag'] = $this->input->post('ci_flag');
		$data['nci_db_flag'] = $this->input->post('nci_db_flag');			
		$data['cn_us'] = $this->input->post('cn_or_us');			
		$ret = $this->app_info_model->add_app($data);
		if($ret == '100'){
			$this->_message($data['app_name']."已经存在!");
		}elseif($ret != '0'){
                        $this->_message($ret."不能为空!");
                }
		$data['list'] = $this->app_info_model->get_app_info();
                $this->_template ( $this->language . '/all_app', $data );
	
	}		

}
